﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using DAO;
using DTO;
namespace DAO
{
    public partial class NCC_DAO
    {
        public bool ThemNCC(NCC ncc_dto)
        {
            DataProvider dp = new DataProvider();
            SqlParameter[] Parameter = new SqlParameter[4];

            Parameter[0] = new SqlParameter("@MaNCC", ncc_dto.MaNCC);
            Parameter[1] = new SqlParameter("@TenNCC", ncc_dto.TenNCC);
            Parameter[2] = new SqlParameter("@DiaChi", ncc_dto.DiaChi);
            Parameter[3] = new SqlParameter("@DienThoai", ncc_dto.DienThoai);
            return dp.ExecutenonQuery("sp_ThemNCC", Parameter);
        }
        public bool CapNhatNCC(NCC ncc_dto)
        {
            DataProvider dp = new DataProvider();
            SqlParameter[] Parameter = new SqlParameter[4];

            Parameter[0] = new SqlParameter("@MaNCC", ncc_dto.MaNCC);
            Parameter[1] = new SqlParameter("@TenNCC", ncc_dto.TenNCC);
            Parameter[2] = new SqlParameter("@DiaChi", ncc_dto.DiaChi);
            Parameter[3] = new SqlParameter("@DienThoai", ncc_dto.DienThoai);
            return dp.ExecutenonQuery("sp_CapNhatNCC", Parameter);
        }
        public bool XoaNCC(NCC ncc_dto)
        {
            DataProvider dp = new DataProvider();
            SqlParameter[] Parameter = new SqlParameter[1];

            Parameter[0] = new SqlParameter("@MaNCC", ncc_dto.MaNCC);
            return dp.ExecutenonQuery("sp_XoaNCC", Parameter);
        }
        public DataTable DanhSachNCC()
        {
            DataProvider dp = new DataProvider();
            DataTable dt = new DataTable();

            dt = dp.ExecuteQuery("sp_DanhSachNCC");
            return dt;
        }
        public string MaNCCTang()
        {
            DataProvider dp = new DataProvider();
            DataTable dt = new DataTable();

            dt = dp.ExecuteQuery("sp_MaNCC_Tang");
            return dt.Rows[0][0].ToString();
        }
        public DataTable DanhSachNCC_Ma(string strMa)
        {
            DataProvider dp = new DataProvider();
            DataTable dt = new DataTable();
            SqlParameter[] Parameter = new SqlParameter[1];

            Parameter[0] = new SqlParameter("@MaNCC", strMa);
            dt = dp.ExecuteQuery("sp_DanhSachNCC_Ma", Parameter);
            return dt;
        }
        public DataTable DanhSachNCC_MaNVL(string strMa)
        {
            DataProvider dp = new DataProvider();
            DataTable dt = new DataTable();
            SqlParameter[] Parameter = new SqlParameter[1];

            Parameter[0] = new SqlParameter("@MaNVL", strMa);
            dt = dp.ExecuteQuery("sp_DanhSachNCC_MaNVL", Parameter);
            return dt;
        }
    }
}
